asm
  ld sp,$99FF
  end asm

#include "./library/pacmandelay.bas"
#include "./library/smsrnd.bas"


dim eee as uinteger at $7010
dim seed as uinteger at $7012
dim ee0 as uinteger at $7014
dim ee1 as uinteger at $7016
dim ee2 as uinteger at $7018
dim ee3 as uinteger at $701A
dim eex as uinteger at $702C
dim eey as uinteger at $702E

sub superwingputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte,tat1 as ubyte):
  poke $8000+(((txp1 bxor 31) band 31) bor ((typ1 band 32)bxor 32)  )*32+typ1 ,tch1
  poke $8800+(((txp1 bxor 31) band 31) bor ((typ1 band 32)bxor 32)  )*32+typ1,tat1
  end sub

sub superwingputcharfix(txp2 as uinteger,typ2 as uinteger,tch2 as ubyte,tat2 as ubyte):
  superwingputchar(txp2,(typ2 mod 28) - ((int(typ2/28))*28) ,tch2,tat2)
  end sub


for ee0=0 to 31
  for ee1=0 to 31
    ee2=seed:seed=smsrnd(seed)
    ee2=seed:seed=smsrnd(seed)
    superwingputcharfix(ee1,ee0,$60+(seed mod 9),ee2 band 15)
    poke $A180,127  '--?
    'pacmandelay(5000)
    next:next

for ee0=0 to 15
  for ee1=0 to 15
    superwingputcharfix(ee1+13,ee0+15,ee0*16+ee1,2)
    poke $A180,127  '--?
    next:next


eee=0:eex=8:eey=8
do

superwingputcharfix(3,1,48+((int(eee/10000)) mod 10),0)
superwingputcharfix(4,1,48+((int(eee/1000)) mod 10),0)
superwingputcharfix(5,1,48+((int(eee/100)) mod 10),0)
superwingputcharfix(6,1,48+((int(eee/10)) mod 10),0)
superwingputcharfix(7,1,48+(eee mod 10),0)

ee0=peek($A000) bxor $FF
superwingputcharfix(5,2,48+((int(ee0/100)) mod 10),0)
superwingputcharfix(6,2,48+((int(ee0/10)) mod 10),0)
superwingputcharfix(7,2,48+(ee0 mod 10),0)

ee1=ee0

ee0=peek($A080) bxor $FF
superwingputcharfix(5,3,48+((int(ee0/100)) mod 10),0)
superwingputcharfix(6,3,48+((int(ee0/10)) mod 10),0)
superwingputcharfix(7,3,48+(ee0 mod 10),0)

eex=eex+((ee1 band 2)/2)-((ee1 band 4)/4)
eey=eey+((ee0 band 8)/8)-((ee1 band 1)/1)

superwingputcharfix(eex,eey,eee mod $60,1)


ee0=peek($A100) bxor $FF
superwingputcharfix(5,4,48+((int(ee0/100)) mod 10),0)
superwingputcharfix(6,4,48+((int(ee0/10)) mod 10),0)
superwingputcharfix(7,4,48+(ee0 mod 10),0)



eee=eee+1
loop





do:loop







do
for ee0=0 to 63
  for ee1=0 to 31
    ee2=seed:seed=smsrnd(seed)
    ee2=seed:seed=smsrnd(seed)
    superwingputchar(ee1,ee0,seed band 127,ee2 band 15)
    poke $A180,127  '--?
    pacmandelay(3000)
    next:next
loop
do:loop





do
for eee=$000 to $FFF
  seed=smsrnd(seed)
  poke eee+$8000,seed
  seed=smsrnd(seed)
  poke eee+$8800,seed
  poke $A180,127  '--?
  pacmandelay(3000)
  next
loop
do:loop










do
for eee=$8000 to $8FFF
  seed=smsrnd(seed)
  poke eee,seed
  poke $A180,127  '--?
  pacmandelay(3000)
  next
loop
do:loop















'static ADDRESS_MAP_START( superwng_map, AS_PROGRAM, 8, superwng_state )
'AM_RANGE(0x0000, 0x3fff) AM_ROM
'AM_RANGE(0x4000, 0x6fff) AM_ROMBANK("bank1")
'AM_RANGE(0x7000, 0x7fff) AM_RAM
'AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(superwng_bg_vram_w) AM_SHARE("videorabg")
'AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(superwng_fg_vram_w) AM_SHARE("videorafg")
'AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(superwng_bg_cram_w) AM_SHARE("colorrabg")
'AM_RANGE(0x8c00, 0x8fff) AM_RAM_WRITE(superwng_fg_cram_w) AM_SHARE("colorrafg")
'AM_RANGE(0x9800, 0x99ff) AM_RAM
'AM_RANGE(0xa000, 0xa000) AM_READ_PORT("P1")
'AM_RANGE(0xa000, 0xa000) AM_WRITE(superwng_hopper_w)
'AM_RANGE(0xa080, 0xa080) AM_READ_PORT("P2")
'AM_RANGE(0xa100, 0xa100) AM_READ_PORT("DSW1")
'AM_RANGE(0xa100, 0xa100) AM_WRITE(superwng_sound_interrupt_w)
'AM_RANGE(0xa180, 0xa180) AM_READ_PORT("DSW2")
'AM_RANGE(0xa180, 0xa180) AM_WRITENOP // watchdog? int ack?
'AM_RANGE(0xa181, 0xa181) AM_WRITE(superwng_nmi_enable_w)
'AM_RANGE(0xa182, 0xa182) AM_WRITE(superwng_tilebank_w)
'AM_RANGE(0xa183, 0xa183) AM_WRITE(superwng_flip_screen_w)
'AM_RANGE(0xa184, 0xa184) AM_WRITE(superwng_cointcnt1_w)
'AM_RANGE(0xa185, 0xa185) AM_WRITE(superwng_unk_a185_w)  // unknown, always(?) 0
'AM_RANGE(0xa186, 0xa186) AM_WRITE(superwng_cointcnt2_w)
'AM_RANGE(0xa187, 0xa187) AM_WRITE(superwng_unk_a187_w) // unknown, always(?) 0
'ADDRESS_MAP_END









